home *** CD-ROM | disk | FTP | other *** search
- package symantec.itools.db.pro;
-
- import java.util.Enumeration;
- import java.util.Hashtable;
- import symantec.itools.db.net.NetRecord;
- import symjava.sql.SQLException;
-
- class RecordTree {
- NetRecord _rec;
- Hashtable _detBlocks;
-
- RecordTree() {
- this._rec = null;
- this._detBlocks = null;
- }
-
- RecordTree(NetRecord r) {
- this._rec = r;
- this._detBlocks = null;
- }
-
- NetRecord getRecord() {
- return this._rec;
- }
-
- boolean isValidRec() {
- return this._rec != null && this._rec.getState() != 105;
- }
-
- synchronized void freeRecordBlocks() {
- if (this.isValidRec()) {
- this._rec.setState((byte)105);
- }
-
- this._rec = null;
- if (this._detBlocks != null) {
- Enumeration e = this._detBlocks.elements();
-
- while(e.hasMoreElements()) {
- RecordSet b = (RecordSet)e.nextElement();
- if (b != null) {
- b.freeRecordTrees();
- }
- }
-
- this._detBlocks.clear();
- this._detBlocks = null;
- }
- }
-
- synchronized RecordSet getRecordSet(RelViewPos pos) throws SQLException {
- RecordSet rb = this.getDetailRecordSet(pos);
- if (pos.over()) {
- return rb;
- } else {
- RecordTree rt = rb.getRecordTree(pos);
- return !rt.isValidRec() ? rb : rt.getRecordSet(pos.next());
- }
- }
-
- private RecordSet getDetailRecordSet(RelViewPos pos) {
- if (this._detBlocks == null) {
- this._detBlocks = new Hashtable();
- }
-
- Integer i = new Integer(pos.getID());
- RecordSet rb = (RecordSet)this._detBlocks.get(i);
- if (rb == null) {
- rb = new RecordSet(pos.cloneAtCurrentPos());
- this._detBlocks.put(i, rb);
- }
-
- return rb;
- }
- }
-